<template>
	<view>
		<view class="mainpadding">
			<view class="mainpadding4 bgc" style="padding: 40rpx 120rpx;">
				<view class="flexcolumn">
					<view class="flexcolumn">
						<view class="xiaobai titletext">总收益(金币)</view>
						<view class="xiaobai titletext bold margin_top2" style="font-size: 70rpx;">{{list.total_sy}}</view>
					</view>
					<view class="flexbetween margin_top6" style="width: 100%;">
						<view class="flexcolumn">
							<view class="xiaobai titletext">已结算(金币)</view>
							<view class="xiaobai titletext bold margin_top2" style="font-size: 50rpx;">{{list.total_ysy}}</view>
						</view>
						<view class="flexcolumn">
							<view class="xiaobai titletext">未结算(金币)</view>
							<view class="xiaobai titletext bold margin_top2" style="font-size: 50rpx;">{{list.total_wsy}}</view>
						</view>
					</view>
				</view>
				
			</view>
			<view class="mainpadding_top ffffff radius">
				<view class="tab_nav">
					<view class="navTitle" v-for="(item,index) in navList" :key="index">
						<view :class="{'active':isActive === index}" @click="checked(index)">
							{{item.title}}
						</view>
					</view>
				</view>
				<view class="margin_top xiahuaxian flexbetween" v-for="item in list.data" :key="item.id">
					<view class="">
						<view class="xiaohui smalltext">{{item.createtime_text}}</view>
						<view class="xiaohei bold titletext margin_top2">{{item.memo}}</view>
						<view class="flexleft margin_top2">
							<image :src="item.user.avatar_text" style="width: 50rpx;height: 50rpx;border-radius: 50%;" class="margin_right1" mode=""></image>
							<text class="xiaohei strongtext margin_right1">{{item.user.nickname}}</text>
							<text class="xiaohui strongtext ">{{item.user.mobile}}</text>
						</view>
					</view>
					<view class="titletext bold xiaohei" style="font-size: 36rpx;">{{item.money}}</view>
				</view>
			</view>
			
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				isActive: 0,
				navList: [{
					index: 0,
					title: "已结算收益"
				},{
					index: 1,
					title: '未结算收益'
				}, ],
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad() {
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this
				let url = "/api/user/plgSy"
				let data = {
					page: page || 1,
					limit: _this.limit,
					js_status:this.isActive==0?2:1
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			checked(index) {
				this.isActive = index
				this.list = {}
				this.init()
			},
		}
	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #f9f9f9;
	}
	.bgc{
		background: linear-gradient(90deg, #2361FF 0%, #8AABFF 100%);
		border-radius: 20rpx;
	}
	.tab_nav {
		background-color: #fff;
		display: flex;
		justify-content: center;
		align-items: center;
		padding-bottom: 11rpx;
	}
	
	.tab_nav .navTitle {
		height: 90rpx;
		line-height: 90rpx;
		width: 100%;
		text-align: center;
		font-size: 30rpx;
		font-weight: bold;
		color: #999999;
	}
	
	.active {
		font-size: 30rpx;
		color: #333333;
		font-weight: bold;
		position: relative;
	}
	
	.active::after {
		content: "";
		position: absolute;
		width: 48rpx;
		height: 6rpx;
		// background: linear-gradient(90deg, #2361FF 0%, #FFFFFF 100%);
		background-color: #333;
		background-size: 100% 100%;
		left: 0rpx;
		right: 0rpx;
		bottom: 0rpx;
		margin: auto;
	}
</style>
